package exsun.jt808.data.upload_data.jt808;

import exsun.jt808.data.upload_data.Jt808EntityBase;
import lombok.Data;

/**
 * 数据上行透传
 */
@Data
public class UplinkPassthrough<T> extends Jt808EntityBase {
    /**
     * 透传消息类型:
     * 0:GNSS 模块详细定位数据
     * 11:道路运输证 IC 卡信息
     * 65:串口 1 透传
     * 66:串口 2 透传
     * 0xF0-0xFF :用户自定义透传
     * 【智能安防系统补充：】
     * 0xF7: 状态查询
     * 0xF8: 信息查询
     */
    private int msgType;
    /**
     * 透传消息内容
     * 【智能安防系统补充：】
     * 消息列表总数：byte
     * 外设消息结构：
     * 外设ID：byte
     * 消息长度：byte
     * 消息内容：
     * 外设状态信息（msgType = 0xF7）：
     * 工作状态：byte
     * 0x01：正常工作
     * 0x02：待机状态
     * 0x03：升级维护
     * 0x04：设备异常
     * 0x10：断开连接
     * 报警状态：dword
     * 按位设置：0表示无，1表示有
     * bit0：摄像头异常
     * bit1：主存储器异常
     * bit2：辅存储器异常
     * bit3：红外补光异常
     * bit4：扬声器异常
     * bit5：电池异常
     * bit6~bit9：预留
     * bit10：通讯模块异常
     * bit11：定位模块异常
     * bit12~bit31：预留
     * 外设系统信息（msgType = 0xF8）：
     * 公司名称长度 byte
     * 公司名称    byte[n1]
     * 产品型号长度 byte
     * 产品型号    byte[n2]
     * 硬件版本号长度 byte
     * 硬件版本号 byte[n3]
     * 软件版本号长度 byte
     * 软件版本号 byte[n4]
     * 设备ID长度 byte
     * 设备ID byte[n5]
     * 客户代码长度 byte
     * 客户代码 byte[n6]
     * 长度：0～32
     * 【名称：采用 ASCII 表示(例如：软件版本号SV1.1.0
     * 表示为0x53 0x56 0x31 0x2E 0x31 0x2E 0x30)】
     */

    /**
     * 消息列表总数（安防系统协议）
     */
    private int infosCount;

    /**
     * 外设ID（安防系统协议）
     */
    private int peripId;

    /**
     * 消息长度（安防系统协议）
     */
    private int infoLength;

//    private String content;

    private T content;

    /**
     * 地址码(中科建德)
     */
    private int addressCode;

    /**
     * 功能码(中科建德)
     */
    private int functionCode;

    /**
     * 返回有效字节数
     */
    private int codeNum;

    /**
     * PM2.5(中科建德)
     */
    private int pmTwoPointFive;

    /**
     * PM10(中科建德)
     */
    private int pmTen;

    /**
     * 校验码低位(中科建德)
     */
    private int low;

    /**
     * 校验码高位(中科建德)
     */
    private int high;


    public int getMsgType() {
        return msgType;
    }

    public void setMsgType(int msgType) {
        this.msgType = msgType;
    }

    private PeripStatusInfo peripStatusInfo;

    private PeripSystemInfo peripSystemInfo;


    public int getInfosCount() {
        return infosCount;
    }

    public void setInfosCount(int infosCount) {
        this.infosCount = infosCount;
    }

    public int getPeripId() {
        return peripId;
    }

    public void setPeripId(int peripId) {
        this.peripId = peripId;
    }

    public int getInfoLength() {
        return infoLength;
    }

    public void setInfoLength(int infoLength) {
        this.infoLength = infoLength;
    }

    public T getContent() {
        if (msgType == 0xF7) {
            return (T) getPeripStatusInfo();
        }
        if (msgType == 0xF8) {
            return (T) getPeripSystemInfo();
        }
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }

    public PeripStatusInfo getPeripStatusInfo() {
        return peripStatusInfo;
    }

    public void setPeripStatusInfo(PeripStatusInfo peripStatusInfo) {
        this.peripStatusInfo = peripStatusInfo;
    }

    public PeripSystemInfo getPeripSystemInfo() {
        return peripSystemInfo;
    }

    public void setPeripSystemInfo(PeripSystemInfo peripSystemInfo) {
        this.peripSystemInfo = peripSystemInfo;
    }

    //    public String getContent() {
//        return content;
//    }
//
//    public void setContent(String content) {
//        this.content = content;
//    }

    /**
     * 外设状态信息
     */
    public class PeripStatusInfo {
        /**
         * 工作状态
         */
        private int workStatus;

        public int getWorkStatus() {
            return workStatus;
        }

        public void setWorkStatus(int workStatus) {
            this.workStatus = workStatus;
        }

        // 0表示无 1表示有
        /**
         * 摄像头异常:bit0
         */
        private int cameraExcep;

        /**
         * 主储存器异常:bit1
         */
        private int mainStorageExcep;

        /**
         * 辅储存器异常:bit2
         */
        private int auxiliaryStorageExcep;

        /**
         * 红外补光异常:bit3
         */
        private int infraredSuppLightExcep;

        /**
         * 扬声器异常:bit4
         */
        private int speakerExcep;

        /**
         * 电池异常:bit5
         */
        private int batteryExcep;

        /**
         * 通讯模块异常:bit10
         */
        private int communicationModuleExcep;

        /**
         * 定位模块异常:bit11
         */
        private int orientationModuleExcep;

        public int getCameraExcep() {
            return cameraExcep;
        }

        public void setCameraExcep(int cameraExcep) {
            this.cameraExcep = cameraExcep;
        }

        public int getMainStorageExcep() {
            return mainStorageExcep;
        }

        public void setMainStorageExcep(int mainStorageExcep) {
            this.mainStorageExcep = mainStorageExcep;
        }

        public int getAuxiliaryStorageExcep() {
            return auxiliaryStorageExcep;
        }

        public void setAuxiliaryStorageExcep(int auxiliaryStorageExcep) {
            this.auxiliaryStorageExcep = auxiliaryStorageExcep;
        }

        public int getInfraredSuppLightExcep() {
            return infraredSuppLightExcep;
        }

        public void setInfraredSuppLightExcep(int infraredSuppLightExcep) {
            this.infraredSuppLightExcep = infraredSuppLightExcep;
        }

        public int getSpeakerExcep() {
            return speakerExcep;
        }

        public void setSpeakerExcep(int speakerExcep) {
            this.speakerExcep = speakerExcep;
        }

        public int getBatteryExcep() {
            return batteryExcep;
        }

        public void setBatteryExcep(int batteryExcep) {
            this.batteryExcep = batteryExcep;
        }

        public int getCommunicationModuleExcep() {
            return communicationModuleExcep;
        }

        public void setCommunicationModuleExcep(int communicationModuleExcep) {
            this.communicationModuleExcep = communicationModuleExcep;
        }

        public int getOrientationModuleExcep() {
            return orientationModuleExcep;
        }

        public void setOrientationModuleExcep(int orientationModuleExcep) {
            this.orientationModuleExcep = orientationModuleExcep;
        }
    }

    /**
     * 外设系统信息
     */
    public class PeripSystemInfo {

        /**
         * 公司名称
         */
        private String companyName;

        private int companyNameLength;

        /**
         * 产品型号
         */
        private String productModel;

        private int productModelLength;

        /**
         * 硬件版本号
         */
        private String hardwareVersion;

        private int hardwareVersionLength;

        /**
         * 软件版本号
         */
        private String softwareVersion;

        private int softwareVersionLength;

        /**
         * 设备ID
         */
        private String deviceId;

        private int deviceIdLength;

        /**
         * 客户代码
         */
        private String clientCode;

        private int clientCodeLength;

        public String getCompanyName() {
            return companyName;
        }

        public void setCompanyName(String companyName) {
            this.companyName = companyName;
        }

        public int getCompanyNameLength() {
            return companyNameLength;
        }

        public void setCompanyNameLength(int companyNameLength) {
            this.companyNameLength = companyNameLength;
        }

        public String getProductModel() {
            return productModel;
        }

        public void setProductModel(String productModel) {
            this.productModel = productModel;
        }

        public int getProductModelLength() {
            return productModelLength;
        }

        public void setProductModelLength(int productModelLength) {
            this.productModelLength = productModelLength;
        }

        public String getHardwareVersion() {
            return hardwareVersion;
        }

        public void setHardwareVersion(String hardwareVersion) {
            this.hardwareVersion = hardwareVersion;
        }

        public int getHardwareVersionLength() {
            return hardwareVersionLength;
        }

        public void setHardwareVersionLength(int hardwareVersionLength) {
            this.hardwareVersionLength = hardwareVersionLength;
        }

        public String getSoftwareVersion() {
            return softwareVersion;
        }

        public void setSoftwareVersion(String softwareVersion) {
            this.softwareVersion = softwareVersion;
        }

        public int getSoftwareVersionLength() {
            return softwareVersionLength;
        }

        public void setSoftwareVersionLength(int softwareVersionLength) {
            this.softwareVersionLength = softwareVersionLength;
        }

        public String getDeviceId() {
            return deviceId;
        }

        public void setDeviceId(String deviceId) {
            this.deviceId = deviceId;
        }

        public int getDeviceIdLength() {
            return deviceIdLength;
        }

        public void setDeviceIdLength(int deviceIdLength) {
            this.deviceIdLength = deviceIdLength;
        }

        public String getClientCode() {
            return clientCode;
        }

        public void setClientCode(String clientCode) {
            this.clientCode = clientCode;
        }

        public int getClientCodeLength() {
            return clientCodeLength;
        }

        public void setClientCodeLength(int clientCodeLength) {
            this.clientCodeLength = clientCodeLength;
        }
    }

}

